package com.easy.west.westclient.client;

import android.content.Context;

import com.easy.west.westclient.api.hotvod.api.HotVodApi;
import com.easy.west.westclient.api.hotvod.api.HotVodImpl;
import com.easy.west.westclient.api.login.api.LoginApi;
import com.easy.west.westclient.api.login.api.LoginImpl;
import com.easy.west.westclient.api.search.api.SearchApi;
import com.easy.west.westclient.api.search.api.SearchImpl;
import com.easy.west.westclient.api.user.api.UserApi;
import com.easy.west.westclient.api.user.api.UserImpl;
import com.easy.west.westclient.api.vod.api.VodApi;
import com.easy.west.westclient.api.vod.api.VodImpl;
import com.easy.west.westclient.api.vodcommen.api.VodCommenApi;
import com.easy.west.westclient.api.vodcommen.api.VodCommenImpl;

/**
 * 网络请求入口
 */
public class MoleClient implements HotVodApi,LoginApi,VodApi,VodCommenApi,SearchApi,UserApi {

    private UserImpl user;
    private SearchImpl search;
    private HotVodImpl hotVod;
    private LoginImpl login;
    private VodImpl vod;
    private VodCommenImpl commen;
    private static MoleClient instance;

    public static MoleClient getInstance(Context context) {
       if (instance==null)
       {
           synchronized (MoleClient.class)
           {
               if (instance == null)
               {
                   instance = new MoleClient(context);
               }
           }
       }
       return instance;
    }

    private MoleClient(Context context)
    {
        user = new UserImpl(context);
        search = new SearchImpl(context);
        vod = new VodImpl(context);
        login = new LoginImpl(context);
        hotVod = new HotVodImpl(context);
        commen = new VodCommenImpl(context);
    }

    /**
     * 注释见接口
     * @return
     */
    @Override
    public String getHotVod() {
        return hotVod.getHotVod();
    }

    @Override
    public String getHotOrLiveNow() {
        return hotVod.getHotOrLiveNow();
    }

    @Override
    public String login(String phone, String password) {
        return login.login(phone,password);
    }

    @Override
    public String regist(String phone, String password) {
        return login.regist(phone,password);
    }

    @Override
    public String isPhoneExit(String phone) {
        return login.isPhoneExit(phone);
    }

    @Override
    public String getPublickey(String phone) {
        return login.getPublickey(phone);
    }

    @Override
    public String updateUsername(String newname, String accesstoken) {
     return login.updateUsername(newname,accesstoken);
    }

    @Override
    public String getAllClass() {
        return vod.getAllClass();
    }

    @Override
    public String getVodByCid(long cid) {
        return vod.getVodByCid(cid);
    }

    @Override
    public String colloctVod(long uid, long vid) {
        return vod.colloctVod(uid, vid);
    }

    @Override
    public String cancelVod(long uid, long vid) {
        return vod.cancelVod(uid, vid);
    }

    @Override
    public String getCollectList(long uid) {
        return vod.getCollectList(uid);
    }

    @Override
    public String isColloect(long uid, long vid) {
        return vod.isColloect(uid, vid);
    }

    @Override
    public String getHotAlbum() {
        return vod.getHotAlbum();
    }

    @Override
    public String getAllAlbum() {
        return vod.getAllAlbum();
    }

    @Override
    public String getCommens(long vid,int num) {
        return commen.getCommens(vid,num);
    }

    @Override
    public String sendLiveCommens(long lid, long owner_id, String access_token, long target_id, int type, String content) {
        return commen.sendLiveCommens(lid,owner_id,access_token,target_id,type,content);
    }

    @Override
    public String sendVodCommens(long vod, long owner_id, String access_token, long target_id, int type, String content) {
        return commen.sendVodCommens(vod,owner_id,access_token,target_id,type,content);
    }

    @Override
    public String search(String name) {
        return search.search(name);
    }

    @Override
    public String followuser(String accesstoken, long onwerId, long targetId) {
        return user.followuser(accesstoken,onwerId,targetId);
    }

    @Override
    public String getMyfollowerList(int num, long ownerId) {
        return user.getMyfollowerList(num,ownerId);
    }

    @Override
    public String isfollow(String accesstoken, long targetId) {
        return user.isfollow(accesstoken,targetId);
    }

    @Override
    public String getMyfollowList(int num, String access_token) {
        return user.getMyfollowList(num,access_token);
    }

    @Override
    public String cancelfollow(long target_id, String access_token) {
        return user.cancelfollow(target_id,access_token);
    }
}
